package 享元模式;

import java.awt.*;
import java.util.HashMap;
import java.util.Map;

// 享元工厂类
class ShapeFactory {
    private static final Map<Color, Shape> circleMap = new HashMap<>();
 
    public static Shape getCircle(Color color) {
        Shape circle = circleMap.get(color);
 
        if (circle == null) {
            circle = new Circle(color);
            circleMap.put(color, circle);
        }
 
        return circle;
    }
}